  import java.util.Scanner;
  public class TokenizeString{
    public static void main(String[] args){
       Scanner scanner = new Scanner(System.in);
    
       System.out.println("Enter string to tokenize: ");
    
       String str = scanner.nextLine();

       System.out.println("Using blank and tab characters as delimiters: ");
       String[] tokens1 = str.split("[ \t]+");
       for(int k = 0; k < tokens1.length; k++)
         System.out.println(tokens1[k]);

      System.out.println("Using the delimiters: \"[ \\t.,;:?!]+\"");
      String[] tokens2 = str.split("[ \t.,;:?!]+");
      for(String token : tokens2)
         System.out.println(token);
    
      scanner.close();
    }
 }
